﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PayloadTracker.APRS
{
    public partial class NMEATextProviderSetup : IAPRSProviderSetup
    {
        public NMEATextProviderSetup()
        {
            InitializeComponent();
        }

        public override void Reset()
        {
            txtFile.Text = string.Empty;
            txtCallsign.Text = string.Empty;
            numMultiplier.Value = 1;

        }
        public override bool ValidateInput()
        {
            try
            {
                return System.IO.File.Exists(txtFile.Text) && txtCallsign.Text.Length > 0;
            }
            catch (System.Exception)
            {
                return false;
            }
        }
        public override IAPRSProvider CreateInstance()
        {
            return new APRS.NMEATextProvider(txtCallsign.Text,txtFile.Text, ((float)numMultiplier.Value));
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();
            ofd.Filter = "All Files (*.*)|*.*";
            ofd.RestoreDirectory = true;
            ofd.CheckFileExists = true;

            if(ofd.ShowDialog() == DialogResult.OK)
            {
                txtFile.Text = ofd.FileName;
            }
        }
    }
}
